<SCRIPT language="javascript">
function CheckField() {
	var lReturn=true
	with (document.frmForm) {
		if (Back.TAG==0) {
			if (edtDESCRIPTION.value == "") {
				alert("Please do not leave the Description field blank.")
				edtDESCRIPTION.focus()
				lReturn=false
			} else if (edtGROUPID.value == "" || selGROUPID.value == "") {
				alert("Please do not leave the Group field blank.")
				lReturn=false
			} else {
				lReturn=true
			}
		}
	}
return (lReturn)
}
</SCRIPT>
<CFSET nameType="eWorkSked">
<CFSET sGroup="">
<CFSET sDescription="">
<CFSET sRouteCode="">
<CFSET bShared="N">
<CFSET sTitle = "Create an #nameType# File">
<CFIF IsDefined("url.edit")>
	<CFSET sID = "#decrypt(url.edit, client.ek)#">
<CFELSEIF IsDefined("url.replicate")>
	<CFSET sID = "#decrypt(url.replicate, client.ek)#">
</CFIF>
<CFIF IsDefined("url.edit") OR IsDefined("url.replicate")>
	<CFQUERY NAME="GetRecords" DATASOURCE="#client.company_dsn#">
		SELECT * FROM ECRGWORKSCHED
		WHERE WSCODE = '#sID#'
	</CFQUERY>
	<CFSET sGroup = GetRecords.WSGROUP>
	<CFSET sDescription = GetRecords.WSDESCRIPTION>
	<CFSET sRouteCode = GetRecords.formcode>
	<CFSET bShared = GetRecords.ISSHARED>
	<CFIF NOT GetRecords.RecordCount>
		<CFLOCATION URL="./" ADDTOKEN="No">
	</CFIF>
</CFIF>
<CFQUERY NAME="qryGroup" DATASOURCE=#client.company_dsn#>
	SELECT DISTINCT WSGROUP FROM ECRGWORKSCHED
	WHERE  WSGROUP IS NOT NULL AND #sqlSTRLEN#(WSGROUP) > 0
	ORDER BY WSGROUP
</CFQUERY>

<CFQUERY NAME="qryGeteForms" DATASOURCE="#client.company_dsn#">
	SELECT FORMCODE,DESCRIPTION FROM ECRGFORMS 
	WHERE FORMTYPE = 'eform'
		AND TABLENAME_FK='CINWORKSCHED'
</CFQUERY>

<CFMODULE TEMPLATE="#client.common_path#cfm_wswindow.cfm" TITLE="#sTitle#">
<TABLE BORDER=0 CELLPADDING=2 CELLSPACING=0 WIDTH="100%" <CFOUTPUT>BGCOLOR="##FFFFFF"</CFOUTPUT>>
	<FORM METHOD="post" ONSUBMIT="return CheckField();" NAME="frmForm">
	<TR>
		<TD COLSPAN=6>
			<INPUT CLASS="bitbtn" TYPE="submit" NAME="btnAction" VALUE=
				<CFIF IsDefined("form.btnAddWS")> "Add"
				<CFELSEIF IsDefined("url.edit")> "Save"
				<CFELSE> "Copy"
				</CFIF>>
			<INPUT CLASS="bitbtn" TYPE="submit" NAME="btnBackMgr" VALUE="Back" TAG="0" ONCLICK="this.TAG=1">
			<HR>
		</TD>
	</TR>
	<CFOUTPUT>
		<CFIF isDefined("url.edit")>
			<INPUT TYPE="HIDDEN" NAME="hidWSCode" VALUE="#sID#">
			<CFSET isReadOnly ="READONLY">
		<CFELSE>
			<INPUT TYPE="HIDDEN" NAME="hidWSCode" VALUE="#createUUID()#">
			<CFSET isReadOnly ="">
		</CFIF>
	</CFOUTPUT>
	<TR>
		<TD>
			<TABLE BORDER=0 CELLPADDING=2 CELLSPACING=0 WIDTH="100%">
				<TR>
					<TD NOWRAP ALIGN="LEFT">Group:</TD>
					<TD>  *</TD>
					<TD>
						<CFIF isDefined("Form.btnAddWS")>
							<input type="Text" name="edtGROUPID" size="55" maxlength="60" value=""
								<CFIF qryGroup.RecordCount>onblur="if (this.value == '') { document.frmForm.selGROUPID.disabled=false; document.frmForm.selGROUPID.selectedIndex=1;} ;"</CFIF>>
							<input type="hidden" name="hidedtGROUPID" value="">
							<CFIF qryGroup.RecordCount>
								<select name="selGROUPID" onchange="if (this.selectedIndex == 0) {document.frmForm.edtGROUPID.disabled=false;} else {document.frmForm.edtGROUPID.disabled=true;};" >
									<option value="">--select group---
									<CFOUTPUT QUERY="qryGroup">
										<option value="#qryGroup.WSGROUP#">#qryGroup.WSGROUP#
									</CFOUTPUT>
								</select>
								<input type="hidden" name="hidselGROUPID" value="">
							</CFIF>
						<CFELSE>
							<CFOUTPUT>
								<input type="Text" name="edtGROUPID" size="55" maxlength="60" value=""
									 <CFIF qryGroup.RecordCount>DISABLED</CFIF>>
							</CFOUTPUT>
							<input type="hidden" name="hidedtGROUPID" value="#qryGroup.GROUPID#">
							<select name="selGROUPID" onchange="if (this.selectedIndex == 0) {document.frmForm.edtGROUPID.disabled=false;} else {document.frmForm.edtGROUPID.disabled=true;};">
								<option value="">------Select Group------</option>
								<CFOUTPUT QUERY="qryGroup">
									<option value="#qryGroup.WSGROUP#"
										<CFIF sGROUP IS qryGroup.WSGROUP>selected</CFIF>>#qryGroup.WSGROUP#
									</option>
								</CFOUTPUT>
							</select>
							<input type="hidden" name="hidselGROUPID" value="#qryGroup.GROUPID#">
						</CFIF>
					</TD>
				</TR>
				<TR>
					<CFOUTPUT>
						<TD ALIGN="LEFT">Description</TD>
						<TD> *</TD>
						<TD COLSPAN="2">
							<INPUT TYPE="TEXT" NAME="edtDESCRIPTION" VALUE="#htmlEditFormat(sDescription)#" MAXLENGTH="60" SIZE="60">
							<INPUT TYPE="HIDDEN" NAME="hidedtDESCRIPTION" VALUE="#sDescription#">
						</TD>
					</CFOUTPUT>
				</TR>
				<TR>
					<TD NOWRAP ALIGN="LEFT">eForm:</TD>
					<TD></TD>
					<TD COLSPAN="2" WIDTH="100%">
						<SELECT NAME="selRoute">
							<OPTION VALUE="">------ Select eForm ------</OPTION>
							<CFOUTPUT QUERY="qryGeteForms">
								<OPTION VALUE="#qryGeteForms.formcode#" <CFIF sRouteCode EQ qryGeteForms.formcode> SELECTED </CFIF>>
									#qryGeteForms.description#
								</OPTION>
							</CFOUTPUT>
						</SELECT>
					</TD>
				</TR>
				<TR>
					<CFOUTPUT>
						<TD NOWRAP ALIGN="LEFT">Share to All</TD>
						<TD> </TD>
						<TD COLSPAN="2" WIDTH="100%">
							<INPUT TYPE="checkbox" NAME="chkShare" <CFIF lcase(bShared) EQ "Y">CHECKED</CFIF>  VALUE="Y" >
						</TD>
					</CFOUTPUT>
				</TR>
			</TABLE>
		</TD>
	</TR>
	</FORM>
</TABLE>
<HR>
<I>* - Field that requires a value.</I>
<CFMODULE TEMPLATE="#client.common_path#cfm_wswindow.cfm" TOP="False">
